home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / Delphi 3.0 / DATA.Z / CALIMPL.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-01-30  |  7.7 KB  |  312 lines

  1. unit CalImpl;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, ActiveX, Classes, Controls, Graphics, Menus, Forms, StdCtrls,
  7.   ComServ, StdVCL, AXCtrls, DelLib, Calendar, Grids;
  8.  
  9. type
  10.   TCalendarX = class(TActiveXControl, ICalendarX)
  11.   private
  12.     { Private declarations }
  13.     FDelphiControl: TCalendar;
  14.     FEvents: ICalendarXEvents;
  15.     procedure ChangeEvent(Sender: TObject);
  16.     procedure ClickEvent(Sender: TObject);
  17.     procedure DblClickEvent(Sender: TObject);
  18.     procedure KeyPressEvent(Sender: TObject; var Key: Char);
  19.   protected
  20.     { Protected declarations }
  21.     procedure InitializeControl; override;
  22.     procedure EventSinkChanged(const EventSink: IUnknown); override;
  23.     procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
  24.     function Get_BorderStyle: TxBorderStyle; safecall;
  25.     function Get_CalendarDate: TDateTime; safecall;
  26.     function Get_Color: TColor; safecall;
  27.     function Get_Ctl3D: WordBool; safecall;
  28.     function Get_Cursor: Smallint; safecall;
  29.     function Get_Day: Integer; safecall;
  30.     function Get_Enabled: WordBool; safecall;
  31.     function Get_Font: Font; safecall;
  32.     function Get_GridLineWidth: Integer; safecall;
  33.     function Get_Month: Integer; safecall;
  34.     function Get_ParentColor: WordBool; safecall;
  35.     function Get_ReadOnly: WordBool; safecall;
  36.     function Get_StartOfWeek: Smallint; safecall;
  37.     function Get_UseCurrentDate: WordBool; safecall;
  38.     function Get_Visible: WordBool; safecall;
  39.     function Get_Year: Integer; safecall;
  40.     procedure AboutBox; safecall;
  41.     procedure NextMonth; safecall;
  42.     procedure NextYear; safecall;
  43.     procedure PrevMonth; safecall;
  44.     procedure PrevYear; safecall;
  45.     procedure Set_BorderStyle(Value: TxBorderStyle); safecall;
  46.     procedure Set_CalendarDate(Value: TDateTime); safecall;
  47.     procedure Set_Color(Value: TColor); safecall;
  48.     procedure Set_Ctl3D(Value: WordBool); safecall;
  49.     procedure Set_Cursor(Value: Smallint); safecall;
  50.     procedure Set_Day(Value: Integer); safecall;
  51.     procedure Set_Enabled(Value: WordBool); safecall;
  52.     procedure Set_Font(const Value: Font); safecall;
  53.     procedure Set_GridLineWidth(Value: Integer); safecall;
  54.     procedure Set_Month(Value: Integer); safecall;
  55.     procedure Set_ParentColor(Value: WordBool); safecall;
  56.     procedure Set_ReadOnly(Value: WordBool); safecall;
  57.     procedure Set_StartOfWeek(Value: Smallint); safecall;
  58.     procedure Set_UseCurrentDate(Value: WordBool); safecall;
  59.     procedure Set_Visible(Value: WordBool); safecall;
  60.     procedure Set_Year(Value: Integer); safecall;
  61.     procedure UpdateCalendar; safecall;
  62.   end;
  63.  
  64. implementation
  65. uses CalPg;
  66. { TCalendarX }
  67.  
  68. procedure TCalendarX.InitializeControl;
  69. begin
  70.   FDelphiControl := Control as TCalendar;
  71.   FDelphiControl.OnChange := ChangeEvent;
  72.   FDelphiControl.OnClick := ClickEvent;
  73.   FDelphiControl.OnDblClick := DblClickEvent;
  74.   FDelphiControl.OnKeyPress := KeyPressEvent;
  75. end;
  76.  
  77. procedure TCalendarX.EventSinkChanged(const EventSink: IUnknown);
  78. begin
  79.   FEvents := EventSink as ICalendarXEvents;
  80. end;
  81.  
  82. procedure TCalendarX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
  83. begin
  84.   { Define property pages here.  Property pages are defined by calling
  85.     DefinePropertyPage with the class id of the page.  For example,
  86.       DefinePropertyPage(Class_CalendarXPage); }
  87. end;
  88.  
  89. function TCalendarX.Get_BorderStyle: TxBorderStyle;
  90. begin
  91.   Result := Ord(FDelphiControl.BorderStyle);
  92. end;
  93.  
  94. function TCalendarX.Get_CalendarDate: TDateTime;
  95. begin
  96.   Result := FDelphiControl.CalendarDate;
  97. end;
  98.  
  99. function TCalendarX.Get_Color: TColor;
  100. begin
  101.   Result := FDelphiControl.Color;
  102. end;
  103.  
  104. function TCalendarX.Get_Ctl3D: WordBool;
  105. begin
  106.   Result := FDelphiControl.Ctl3D;
  107. end;
  108.  
  109. function TCalendarX.Get_Cursor: Smallint;
  110. begin
  111.   Result := Smallint(FDelphiControl.Cursor);
  112. end;
  113.  
  114. function TCalendarX.Get_Day: Integer;
  115. begin
  116.   Result := FDelphiControl.Day;
  117. end;
  118.  
  119. function TCalendarX.Get_Enabled: WordBool;
  120. begin
  121.   Result := FDelphiControl.Enabled;
  122. end;
  123.  
  124. function TCalendarX.Get_Font: Font;
  125. begin
  126.   GetOleFont(FDelphiControl.Font, Result);
  127. end;
  128.  
  129. function TCalendarX.Get_GridLineWidth: Integer;
  130. begin
  131.   Result := FDelphiControl.GridLineWidth;
  132. end;
  133.  
  134. function TCalendarX.Get_Month: Integer;
  135. begin
  136.   Result := FDelphiControl.Month;
  137. end;
  138.  
  139. function TCalendarX.Get_ParentColor: WordBool;
  140. begin
  141.   Result := FDelphiControl.ParentColor;
  142. end;
  143.  
  144. function TCalendarX.Get_ReadOnly: WordBool;
  145. begin
  146.   Result := FDelphiControl.ReadOnly;
  147. end;
  148.  
  149. function TCalendarX.Get_StartOfWeek: Smallint;
  150. begin
  151.   Result := Smallint(FDelphiControl.StartOfWeek);
  152. end;
  153.  
  154. function TCalendarX.Get_UseCurrentDate: WordBool;
  155. begin
  156.   Result := FDelphiControl.UseCurrentDate;
  157. end;
  158.  
  159. function TCalendarX.Get_Visible: WordBool;
  160. begin
  161.   Result := FDelphiControl.Visible;
  162. end;
  163.  
  164. function TCalendarX.Get_Year: Integer;
  165. begin
  166.   Result := FDelphiControl.Year;
  167. end;
  168.  
  169. procedure TCalendarX.AboutBox;
  170. begin
  171.   ShowCalendarXAbout;
  172. end;
  173.  
  174. procedure TCalendarX.NextMonth;
  175. begin
  176.   FDelphiControl.NextMonth;
  177. end;
  178.  
  179. procedure TCalendarX.NextYear;
  180. begin
  181.   FDelphiControl.NextYear;
  182. end;
  183.  
  184. procedure TCalendarX.PrevMonth;
  185. begin
  186.   FDelphiControl.PrevMonth;
  187. end;
  188.  
  189. procedure TCalendarX.PrevYear;
  190. begin
  191.   FDelphiControl.PrevYear;
  192. end;
  193.  
  194. procedure TCalendarX.Set_BorderStyle(Value: TxBorderStyle);
  195. begin
  196.   FDelphiControl.BorderStyle := TBorderStyle(Value);
  197. end;
  198.  
  199. procedure TCalendarX.Set_CalendarDate(Value: TDateTime);
  200. begin
  201.   FDelphiControl.CalendarDate := Value;
  202. end;
  203.  
  204. procedure TCalendarX.Set_Color(Value: TColor);
  205. begin
  206.   FDelphiControl.Color := Value;
  207. end;
  208.  
  209. procedure TCalendarX.Set_Ctl3D(Value: WordBool);
  210. begin
  211.   FDelphiControl.Ctl3D := Value;
  212. end;
  213.  
  214. procedure TCalendarX.Set_Cursor(Value: Smallint);
  215. begin
  216.   FDelphiControl.Cursor := TCursor(Value);
  217. end;
  218.  
  219. procedure TCalendarX.Set_Day(Value: Integer);
  220. begin
  221.   FDelphiControl.Day := Value;
  222. end;
  223.  
  224. procedure TCalendarX.Set_Enabled(Value: WordBool);
  225. begin
  226.   FDelphiControl.Enabled := Value;
  227. end;
  228.  
  229. procedure TCalendarX.Set_Font(const Value: Font);
  230. begin
  231.   SetOleFont(FDelphiControl.Font, Value);
  232. end;
  233.  
  234. procedure TCalendarX.Set_GridLineWidth(Value: Integer);
  235. begin
  236.   FDelphiControl.GridLineWidth := Value;
  237. end;
  238.  
  239. procedure TCalendarX.Set_Month(Value: Integer);
  240. begin
  241.   FDelphiControl.Month := Value;
  242. end;
  243.  
  244. procedure TCalendarX.Set_ParentColor(Value: WordBool);
  245. begin
  246.   FDelphiControl.ParentColor := Value;
  247. end;
  248.  
  249. procedure TCalendarX.Set_ReadOnly(Value: WordBool);
  250. begin
  251.   FDelphiControl.ReadOnly := Value;
  252. end;
  253.  
  254. procedure TCalendarX.Set_StartOfWeek(Value: Smallint);
  255. begin
  256.   FDelphiControl.StartOfWeek := TDayOfWeek(Value);
  257. end;
  258.  
  259. procedure TCalendarX.Set_UseCurrentDate(Value: WordBool);
  260. begin
  261.   FDelphiControl.UseCurrentDate := Value;
  262. end;
  263.  
  264. procedure TCalendarX.Set_Visible(Value: WordBool);
  265. begin
  266.   FDelphiControl.Visible := Value;
  267. end;
  268.  
  269. procedure TCalendarX.Set_Year(Value: Integer);
  270. begin
  271.   FDelphiControl.Year := Value;
  272. end;
  273.  
  274. procedure TCalendarX.UpdateCalendar;
  275. begin
  276.   FDelphiControl.UpdateCalendar;
  277. end;
  278.  
  279. procedure TCalendarX.ChangeEvent(Sender: TObject);
  280. begin
  281.   if FEvents <> nil then FEvents.OnChange;
  282. end;
  283.  
  284. procedure TCalendarX.ClickEvent(Sender: TObject);
  285. begin
  286.   if FEvents <> nil then FEvents.OnClick;
  287. end;
  288.  
  289. procedure TCalendarX.DblClickEvent(Sender: TObject);
  290. begin
  291.   if FEvents <> nil then FEvents.OnDblClick;
  292. end;
  293.  
  294. procedure TCalendarX.KeyPressEvent(Sender: TObject; var Key: Char);
  295. var
  296.   TempKey: Smallint;
  297. begin
  298.   TempKey := Smallint(Key);
  299.   if FEvents <> nil then FEvents.OnKeyPress(TempKey);
  300.   Key := Char(TempKey);
  301. end;
  302.  
  303. initialization
  304.   TActiveXControlFactory.Create(
  305.     ComServer,
  306.     TCalendarX,
  307.     TCalendar,
  308.     Class_CalendarX,
  309.     2,
  310.     '{5A56595E-7975-11D0-BE02-00A024D1875C}');
  311. end.
  312.